<script>
    function loadXMLDoc(){
        var xmlhttp;
        if (window.XMLHttpRequest){
            //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlhttp=new XMLHttpRequest();
        }else{
            // IE6, IE5 浏览器执行代码
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }xmlhttp.onreadystatechange=function(){
            if (xmlhttp.readyState==4 && xmlhttp.status==200){
                if(isJsonString(xmlhttp.responseText)){
                    var data = JSON.parse(xmlhttp.responseText);
                    //alert(data.data.info);
                    window.location = '/login';
                }else {
                    document.write(xmlhttp.responseText);
                }
            }
        }
        xmlhttp.open("GET","/admin_init");
        xmlhttp.setRequestHeader('token', localStorage.getItem("token"));
        xmlhttp.send();
    }
    function isJsonString(str) {
        try {
            if (typeof JSON.parse(str) == "object") {
                return true;
            }
        } catch(e) {
        }
        return false;
    }
    loadXMLDoc();
</script>
